

[CmdletBinding(SupportsShouldProcess=$true)]
param(
	[string] $path = ".\Applist.csv"
)

$ScriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$WIshList = import-csv $path


###############################################

# Publisher,ShortName,Name,Version,Binary,Binaryx64,CommandLine,ExtractCmd,Platform,notes
foreach ( $Item in $WishList ) 
{

	$AppFullName = "$($Item.Publisher) $($Item.Name) - $($Item.Version)".trim()


	if ( ! ( test-path "$ScriptPath\$($Item.ShortName)\$AppFullName.$($Item.Class).mdt.ps1" ) ) 
	{
		write-verbose "Make script $AppFullName"

		$SupportedPlatform = ""
		if ( ! [string]::IsNullOrEmpty( $Item.platform ) )
		{
			$SupportedPlatform = "SupportedPlatform = `@(""" + ( ($Item.platform.split("`t")) -join """, """) + """)" 
		}

@"
# Application Import script - DeploymentLive.com

[CmdletBinding(SupportsShouldProcess=`$true)]
param(
	[string] `$Folder  = "$($Item.Folder)",
	[string] `$DPDrive = "DS002"
)

##################################################

`$NamedParams = @{ 
	Path = "`$(`$DPDrive)``:\`$Folder"
	ShortName = "$($Item.ShortName)"
	Name = "$AppFullName"
	WorkingDirectory = "."
	$SupportedPlatform
	CommandLine = "cscript ZTIPowerShell.wsf /ScriptFile:%ScriptRoot%\Extras\Install-Chocolatey.ps1 /Parameters:$($Item.Chocolatey)"
}	

Import-MDTApplication @NamedParams -NoSource

"@.replace("""""","") | out-file -encoding ASCII -append "$ScriptPath\$($Item.ShortName).mdt.ps1"

	}

}





